package com.offcn;
/*
判断数是否是质数
 */
import java.util.Scanner;
public class IsPrime {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个正整数：");
        int num = sc.nextInt();
        System.out.println("请输入"+ num + "个数字");
        int[] arr = new int[num];
        for(int i = 0;i < num;i++) {

            arr[i] = sc.nextInt();
        }

        checkIsPrime(arr,num);
    }
    public static void checkIsPrime(int[] arr,int num) {

        for(int i = 0;i < num;i++) {

            int n = arr[i];
            System.out.println(n + (isPrime(n)?" is prime":" is not prime"));
        }
    }

    public static boolean isPrime(int num) {
        if(num == 0 || num == 1) {
            return false;
        }
        for(int i = 2;i <= Math.sqrt(num);i++) {
            if(num % i == 0) {
                return false;
            }
        }
        return true;
    }
}